<template>
	<view class="left">
		<view class="left-item" v-for="(item, index) in leftlist" :key="index" @click="toggleText(item.id)">
			{{ item.title }}
			<text class="selected-flag" v-if="selectedIndex === index"></text>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				leftlist:[{
					title:'首页',
					id:0
				},{
					title:'已买到的货品',
					id:1
				},{
					title:'摘牌的采购单',
					id:2
				},{
					title:'修改密码',
					id:3
				},{
					title:'员工列表',
					id:4
				},{
					title:'消息列表',
					id:5
				},{
					title:'我的采购',
					id:6
				},{
					title:'我的寄售',
					id:7
				},{
					title:'客服中心',
					id:8
				},{
					title:'供应大厅',
					id:9
				},{
					title:'采购大厅',
					id:10
				},{
					title:'订单融资',
					id:11
				},{
					title:'浏览记录',
					id:12
				}],
				selectedIndex:0
			};
		},
		props:{
			Index:{
				type:Number,
				default:0
			}
		},
		methods: {
			toggleText(index) {
				this.$emit("index", index);
				this.selectedIndex = index;
			},
		},
		watch:{
			Index:function(newvalue,oldvalue){
				console.log(newvalue,oldvalue)
				if(newvalue==14&&oldvalue==7||newvalue==15&&oldvalue==6){
					return
				}
				if(newvalue!=oldvalue){
					this.selectedIndex = newvalue
				}
			}
		}
	};
</script>

<style lang="scss">
	.left {
		padding: 20rpx 0;
		width: 180px;
		background: #fff;
		box-sizing: border-box;
		cursor: pointer;

		.left-item {
			// color: #45b035;
			padding: 38rpx 0 38rpx 40rpx;
			font-size: 28rpx;
			line-height: 44rpx;
			position: relative;

			.selected-flag {
				position: absolute;
				width: 8rpx;
				height: 48rpx;
				top: 38rpx;
				left: 0;
				background: #28a745;
			}
		}

		.active {
			color: #28a745;
		}

		/deep/ .uni-scroll-view-content {
			padding: 20rpx 0;
			width: 360rpx;
			background: #fff;
			box-sizing: border-box;
		}
	}
</style>